# toolchain.cmake

# 设置目标系统名称
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# 指定交叉编译器的路径
set(CROSS_SYSROOT /opt/am335xt3-cross-devkit/arm-arago-linux-gnueabi)
set(CROSS_COMPILE_PATH /opt/am335xt3-cross-devkit/bin)
set(CROSS_PREFIX /opt/am335xt3-cross-devkit/bin/arm-arago-linux-gnueabi-)
set(CMAKE_C_COMPILER /opt/am335xt3-cross-devkit/bin/arm-arago-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /opt/am335xt3-cross-devkit/bin/arm-arago-linux-gnueabi-g++)
set(CMAKE_ASM_COMPILER /opt/am335xt3-cross-devkit/bin/arm-arago-linux-gnueabi-as)
set(CMAKE_AR  /opt/am335xt3-cross-devkit/bin/arm-arago-linux-gnueabi-ar)
set(CROSS_COMPILE_INCLUDE_PATH /opt/am335xt3-cross-devkit/arm-arago-linux-gnueabi/sysroot/usr/include)

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/am335xt3_install)
set(CMAKE_INTERNAL_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/am335xt3_internal_install)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -rdynamic -g0 -Wall -Wshadow -Wundef -Wmissing-prototypes -Wall -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wuninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare")

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lm -ldl")

# 指定库的查找路径
set(CMAKE_LIBRARY_PATH ${CMAKE_INTERNAL_INSTALL_PREFIX}/lib)

# 设置查找路径
set(CMAKE_FIND_ROOT_PATH ${CJSON_ROOT} ${OPENSSL_ROOT})

# 指定查找规则
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# 禁用 CMake 的默认查找路径（如系统路径 /usr 和 /lib）
set(CMAKE_FIND_NO_PACKAGE_PREFIX_PATH TRUE)